<?php
/**
 * $Author: BEESCMS $
 * ============================================================================
 * 网站地址: http://www.beescms.com
 * 您只能在不用于商业目的的前提下对程序代码进行修改和使用；
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/

define('IN_CMS','true');
include('init.php');
$action=isset($_REQUEST['action'])?fl_html(fl_value($_REQUEST['action'])):'flash_ad';
$lang=isset($_REQUEST['lang'])?fl_html(fl_value($_REQUEST['lang'])):get_lang_main();
//主广告列表
if($action=='flash_ad'){
	$page=$_GET['page'];
	include('template/admin_flash_ad.html');
}
//添加主广告
elseif($action=='add'){
	include('template/admin_flash_ad_add.html');
}
//处理添加的主广告
elseif($action=='save_flash_ad'){
	if(empty($_POST['pic'])){msg('<span style="color:red">图片不能为空</span>');}
	if(empty($_POST['lang'])){msg('<span style="color:red">参数传递错误，请重新操作</span>','?action=flash_ad');}
	$pic=cn_substr(trim($_POST['pic']),255);
	$pic_url=cn_substr(trim($_POST['pic_url']),255);
	$pic_text=cn_substr(trim($_POST['pic_text']),255);
	$pic_order=empty($_POST['pic_order'])?10:intval($_POST['pic_order']);
	$GLOBALS['mysql']->query('insert into '.DB_PRE."flash_ad (pic,pic_url,pic_text,pic_order,lang) values ('{$pic}','{$pic_url}','{$pic_text}',{$pic_order},'{$lang}')");
	msg('主广告添加完成','?action=flash_ad&lang='.$lang);
}
//修改主广告
elseif($action=='edit'){
	$id=intval($_GET['id']);
	if(empty($lang)||empty($id)){msg('<span style="color:red">参数传递错误，请重新操作！</span>');}
	$rel=$GLOBALS['mysql']->fetch_asc('select*from '.DB_PRE.'flash_ad where id='.$id." and lang='".$lang."'");
	include('template/admin_flash_ad_edit.html');
}
//处理修改的主广告
elseif($action=='save_edit'){
	if(empty($_POST['id'])){msg('<span style="color:red">参数发生错误，请重新操作</span>');}
	if(empty($_POST['pic'])){msg('<span style="color:red">图片不能为空</span>');}
	if(empty($_POST['lang'])){msg('<span style="color:red">参数传递错误，请重新操作</span>','?action=flash_ad');}
	$pic=cn_substr(trim($_POST['pic']),255);
	$pic_url=cn_substr(trim($_POST['pic_url']),255);
	$pic_text=cn_substr(trim($_POST['pic_text']),255);
	$pic_order=empty($_POST['pic_order'])?10:intval($_POST['pic_order']);
	$id=intval($_POST['id']);
	$GLOBALS['mysql']->query("update ".DB_PRE."flash_ad set pic='{$pic}',pic_url='{$pic_url}',pic_text='{$pic_text}',pic_order={$pic_order} where id={$id}");
	msg('主广告修改成功','?action=flash_ad&lang='.$lang);
}
//删除主广告
elseif($action=='del'){
	$id=intval($_GET['id']);
	$GLOBALS['mysql']->query('delete from '.DB_PRE.'flash_ad where id='.$id);
	msg('删除完成','?action=flash_ad&lang='.$lang);
}
?>
